﻿<Button x:Class="SaturnExplorer.CaptionButton"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             Width="25" Height="18">
    <Button.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Resources/Main.xaml" />
                <ResourceDictionary Source="../Resources/ScrollBarStyle.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Button.Resources>
    <Button.Template>
        <ControlTemplate TargetType="{x:Type Button}">
            <Grid Background="Transparent">
                <Border x:Name="HoverBorder" Margin="0" BorderBrush="{StaticResource CaptionButtonHoverOuterBorderBrush}" BorderThickness="1" CornerRadius="2" Visibility="Collapsed">
                    <Border x:Name="HoverBorderInner" BorderBrush="{StaticResource CaptionButtonHoverInnerBorderBrush}" BorderThickness="1" CornerRadius="1" Background="{DynamicResource CaptionButtonHoverInnerBackgroundBrush}"/>
                </Border>
                <Border x:Name="PressedBorder" Margin="0" BorderBrush="{StaticResource CaptionButtonPressedOuterBorderBrush}" BorderThickness="1" CornerRadius="2" Visibility="Collapsed">
                    <Border x:Name="PressedBorderInner" BorderBrush="{StaticResource CaptionButtonPressedInnerBorderBrush}" BorderThickness="1" CornerRadius="1" Background="{DynamicResource CaptionButtonPressedInnerBackgroundBrush}"/>
                </Border>
                <ContentPresenter Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
            </Grid>
            <ControlTemplate.Triggers>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsMouseOver" Value="True"/>
                        <Condition Property="IsPressed" Value="False"/>
                    </MultiTrigger.Conditions>
                    <Setter Property="Visibility" TargetName="HoverBorder" Value="Visible"/>
                </MultiTrigger>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="Visibility" TargetName="PressedBorder" Value="Visible"/>
                </Trigger>
                <Trigger Property="Background" Value="Red">
                    <Setter Property="BorderBrush" TargetName="HoverBorder" Value="{StaticResource CaptionButtonCloseHoverOuterBorderBrush}"/>
                    <Setter Property="BorderBrush" TargetName="HoverBorderInner" Value="{StaticResource CaptionButtonCloseHoverInnerBorderBrush}"/>
                    <Setter Property="Background" TargetName="HoverBorderInner" Value="{StaticResource CaptionButtonCloseHoverInnerBackgroundBrush}"/>

                    <Setter Property="BorderBrush" TargetName="PressedBorder" Value="{StaticResource CaptionButtonClosePressedOuterBorderBrush}"/>
                    <Setter Property="BorderBrush" TargetName="PressedBorderInner" Value="{StaticResource CaptionButtonClosePressedInnerBorderBrush}"/>
                    <Setter Property="Background" TargetName="PressedBorderInner" Value="{StaticResource CaptionButtonClosePressedInnerBackgroundBrush}"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Button.Template>
</Button>
